package com.atguigu.dga.governance.assess.spec;

import com.atguigu.dga.governance.assess.Assessor;
import com.atguigu.dga.governance.bean.AssessParam;
import com.atguigu.dga.governance.bean.GovernanceAssessDetail;
import com.atguigu.dga.governance.bean.GovernanceMetric;
import com.atguigu.dga.meta.bean.TableMetaInfo;
import com.atguigu.dga.meta.constant.CodeConst;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;


@Component("TEC_OWNER")
public class TecOwnerAssessor extends Assessor {

    @Override
    public void checkProblem(GovernanceAssessDetail governanceAssessDetail , AssessParam assessParam) {
        GovernanceMetric governanceMetric = assessParam.getGovernanceMetric();
        TableMetaInfo tableMetaInfo = assessParam.getTableMetaInfo();
        if(tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName()==null
                ||tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName().trim().length()==0
                || tableMetaInfo.getTableMetaInfoExtra().getTecOwnerUserName().equals(CodeConst.OWNER_UNSET)){
            governanceAssessDetail.setAssessScore(BigDecimal.ZERO);
            governanceAssessDetail.setAssessProblem("未填写技术负责人");

            ////table_meta/table_meta/detail?tableId={tableId}
            String governanceUrl = governanceMetric.getGovernanceUrl();
            governanceUrl=  governanceUrl.replace("{tableId}",tableMetaInfo.getId()+"");
            governanceAssessDetail.setGovernanceUrl(governanceUrl);
        }
    }

//    @Override
//    public GovernanceAssessDetail metricAssess(TableMetaInfo tableMetaInfo, GovernanceMetric governanceMetric) {
//
//
//        System.out.println("表 [" + tableMetaInfo.getTableName() +"] : 考评指标："+governanceMetric.getMetricName() );
//        System.out.println(1/0);
//        return new GovernanceAssessDetail();
//    }
}
